﻿namespace Devonline.Entity;

/// <summary>
/// 证件, 字符串表达式的默认实现
/// </summary>
[DisplayName("证件")]
public class CredentialViewModel : CredentialViewModel<string>, IViewModel, IEntitySet
{
    /// <summary>
    /// 证件的附加信息
    /// </summary>
    [NotMapped]
    public virtual ICollection<CredentialAdditional>? Additionals { get; set; }
    /// <summary>
    /// 通用附件集合, NotMapped 用于记录实体对象上上传的附件
    /// </summary>
    [NotMapped]
    public virtual ICollection<Attachment>? Attachments { get; set; }
}

/// <summary>
/// 证件
/// </summary>
[DisplayName("证件")]
public class CredentialViewModel<TKey> : ViewModel<TKey>, IViewModel<TKey>, IEntitySet<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 证件所有者编号
    /// </summary>
    [DisplayName("证件所有者编号"), Required, MaxLength(36), Excel]
    public virtual TKey? OwnerId { get; set; }
    /// <summary>
    /// 证件类型
    /// </summary>
    [DisplayName("证件类型"), Required, Excel]
    public virtual CredentialType Type { get; set; }
    /// <summary>
    /// 证件上名字
    /// </summary>
    [DisplayName("姓名"), Required, MaxLength(256), Excel]
    public virtual string? Name { get; set; }
    /// <summary>
    /// 证件号码
    /// </summary>
    [DisplayName("证件号码"), MaxLength(256), Unique, Excel]
    public virtual string? Code { get; set; }
    /// <summary>
    /// 签发机关
    /// </summary>
    [DisplayName("签发机关"), MaxLength(36), Excel]
    public virtual string? IssuedBy { get; set; }
    /// <summary>
    /// 有效期始
    /// </summary>
    [DisplayName("有效期始"), Excel]
    public virtual DateTime? StartDate { get; set; }
    /// <summary>
    /// 有效期至
    /// </summary>
    [DisplayName("有效期至"), Excel]
    public virtual DateTime? EndDate { get; set; }
    /// <summary>
    /// 证件照片
    /// </summary>
    [DisplayName("证件照片"), MaxLength(128), BusinessType(IsAttachment = true, Name = "Credential.Image"), Excel]
    public virtual string? Image { get; set; }
    /// <summary>
    /// 证件头像照片
    /// </summary>
    [DisplayName("证件头像照片"), MaxLength(128), BusinessType(IsAttachment = true, Name = "Credential.HeadImage"), Excel]
    public virtual string? HeadImage { get; set; }
    /// <summary>
    /// 备注说明
    /// </summary>
    [DisplayName("备注说明"), MaxLength(256), Excel]
    public virtual string? Description { get; set; }
}